<html>
<head><meta charset="utf-8"><title>doing multiple analysis/replacement steps · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html">doing multiple analysis/replacement steps</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="185318269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318269">(Jan 10 2020 at 15:12)</a>:</h4>
<p>So... I'm trying to get the "substitute type parameters" and the "qualify paths" steps in the "add missing impl members" assist to work together. The problem is that after we've qualified paths, the syntax node we're editing is of course not the actual syntax node anymore, so most analysis doesn't work on it anymore, in particular resolving type parameters.</p>
<p>One option of course would be to do the type parameter substitution purely on syntax, but I don't like that.</p>
<p>This is made harder by the fact that while the edits don't collide themselves (something is either a path to qualify or a type parameter), the paths we qualify can contain type arguments that need to be substituted. E.g. let's say we have <code>Foo&lt;T&gt;</code>, then when qualifying we replace that whole node by <code>foo::Foo&lt;T&gt;</code>, and the <code>T</code>is a completely new node.</p>
<p>The only option I can currently think of is to merge both steps into one, which isn't nice but should at least work <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> </p>
<p>Any ideas, <span class="user-mention" data-user-id="133169">@matklad</span> ?</p>



<a name="185318540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318540">(Jan 10 2020 at 15:15)</a>:</h4>
<p>Tough question.</p>
<p>I think what IntelliJ does in similar situations is that it creates temporary PSI which is attached to some real PSI via a context attributes. On that injected PSI, all the analysis works, so you can just mutate it in place....</p>



<a name="185318704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318704">(Jan 10 2020 at 15:17)</a>:</h4>
<p>First, I am confused by the order here.</p>
<p>It seems like we <em>first</em> should do subst, and then qualification? And not the other way around?</p>



<a name="185318813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318813">(Jan 10 2020 at 15:18)</a>:</h4>
<p>I think no, since we don't want to qualify the paths we substituted as if they were in the original module</p>



<a name="185318915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318915">(Jan 10 2020 at 15:19)</a>:</h4>
<p>I noticed this when trying it on <code>chalk_solve::RustIrDatabase</code>, it qualified the <code>TypeFamily</code> parameter to <code>chalk_ir::TypeFamily</code> even though we actually want our own one</p>



<a name="185318918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318918">(Jan 10 2020 at 15:19)</a>:</h4>
<p>Hm, but if we don't have to qualify the path, it won't be qualifed, no?</p>



<a name="185318945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185318945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185318945">(Jan 10 2020 at 15:19)</a>:</h4>
<p>Could you show an example? I think I am just confused as two what goes where :D</p>



<a name="185319271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319271">(Jan 10 2020 at 15:23)</a>:</h4>
<p>so, we have in our <code>chalk.rs</code>:</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">TypeFamily</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="p">,</span><span class="w"> </span><span class="n">DB</span><span class="o">&gt;</span><span class="w"> </span><span class="n">chalk_solve</span>::<span class="n">RustIrDatabase</span><span class="o">&lt;</span><span class="n">TypeFamily</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">ChalkContext</span><span class="o">&lt;</span><span class="na">&#39;a</span><span class="p">,</span><span class="w"> </span><span class="n">DB</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>but in <code>chalk_solve</code>, the name <code>TypeFamily</code> resolves to <code>chalk_solve::family::TypeFamily</code>. So adding impls results in e.g.</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">custom_clauses</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Vec</span><span class="o">&lt;</span><span class="n">ProgramClause</span><span class="o">&lt;</span><span class="n">chalk_solve</span>::<span class="n">family</span>::<span class="n">TypeFamily</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</pre></div>


<p>because the <code>TF</code> parameter gets first substituted to <code>TypeFamily</code>, and that then resolves to <code>chalk_solve::family::TypeFamily</code> (because qualifying paths resolves everything from the definition of the trait) and hence gets qualified</p>



<a name="185319409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319409">(Jan 10 2020 at 15:24)</a>:</h4>
<p>basically, the qualifying-paths step doesn't know that the substituted things are already from the perspective of the module we're inserting into</p>



<a name="185319413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319413">(Jan 10 2020 at 15:24)</a>:</h4>
<p>Ah, so this is a hygiene issue of sorts?</p>



<a name="185319418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319418">(Jan 10 2020 at 15:25)</a>:</h4>
<p>kind of, yeah</p>



<a name="185319593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319593">(Jan 10 2020 at 15:26)</a>:</h4>
<p>Hm, I still have a feeling that we should do substitution first, but maybe we shouldn't subst syntactically?</p>



<a name="185319649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319649">(Jan 10 2020 at 15:27)</a>:</h4>
<p>Like, if we were <em>rendering</em> <code>hir</code> to syntax, we would first substitute in the hir, and then render a substituted thing</p>



<a name="185319650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319650">(Jan 10 2020 at 15:27)</a>:</h4>
<p>what do you mean?</p>



<a name="185319703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319703">(Jan 10 2020 at 15:27)</a>:</h4>
<p>ok yeah, but then we'd have to be able to actually render whole method definitions from hir</p>



<a name="185319708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319708">(Jan 10 2020 at 15:28)</a>:</h4>
<p>So perhaps <code>substitute_type_params</code> should not return and <code>N</code>, but something like <code>FxHashMap&lt;ast::Type, ast::Type&gt;</code>?</p>



<a name="185319808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319808">(Jan 10 2020 at 15:28)</a>:</h4>
<p>Than, the qualify thing would skip they <code>keys</code> of that map?</p>



<a name="185319859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319859">(Jan 10 2020 at 15:29)</a>:</h4>
<p>well, it would have to do the replacements</p>



<a name="185319883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319883">(Jan 10 2020 at 15:29)</a>:</h4>
<p>because after it's done, the <code>ast::Type</code> keys of that map might not actually exist in the new syntax tree anymore</p>



<a name="185319986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185319986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185319986">(Jan 10 2020 at 15:30)</a>:</h4>
<p>But I think <code>qual</code> can <em>also</em> return just a <code>Map&lt;SyntaxNode, SyntaxNode&gt;</code>? And the separate layer would then \cup those two maps?</p>



<a name="185320021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320021">(Jan 10 2020 at 15:31)</a>:</h4>
<p>kind of, but that's where the problem comes in that the type args are a child node of the path</p>



<a name="185320031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320031">(Jan 10 2020 at 15:31)</a>:</h4>
<p>FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU</p>



<a name="185320043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320043">(Jan 10 2020 at 15:31)</a>:</h4>
<p>yeah</p>



<a name="185320223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320223">(Jan 10 2020 at 15:33)</a>:</h4>
<p>Hm....</p>
<p>It seems overall that the core problem is still that in-place syntax modification just erases essential info</p>



<a name="185320288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320288">(Jan 10 2020 at 15:34)</a>:</h4>
<p>So, some sort of a more diff-oriented approach seems more approriate..</p>



<a name="185320317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320317">(Jan 10 2020 at 15:34)</a>:</h4>
<p>Perhapse we need</p>
<div class="codehilite"><pre><span></span>type AstSubst = Box&lt;Fn(&amp;SyntaxNode) -&gt; Option&lt;SyntaxNode&gt;&gt;;
</pre></div>


<p>and make <code>qual</code> accept that?</p>



<a name="185320362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320362">(Jan 10 2020 at 15:35)</a>:</h4>
<p>Like, the rewsult of <code>qual</code> is actually a similar <code>AstSubst</code>, and looks like one can compose thouse things</p>



<a name="185320381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320381">(Jan 10 2020 at 15:35)</a>:</h4>
<p>It just has to be the right solution, because then it will be math :)</p>



<a name="185320461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185320461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185320461">(Jan 10 2020 at 15:36)</a>:</h4>
<p>hmmm</p>



<a name="185321381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321381">(Jan 10 2020 at 15:46)</a>:</h4>
<p>It's also intresing that IntelliJ just adds imoprts, instead of qualifing parhs</p>



<a name="185321455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321455">(Jan 10 2020 at 15:46)</a>:</h4>
<p>But it does handle both imports and subts correctly (and that was implemented after I've left :D )</p>



<a name="185321479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321479">(Jan 10 2020 at 15:47)</a>:</h4>
<p>would make things easier, but I think in edge cases we would have to qualify paths anyway to avoid collisions, and I personally like giving the choice of importing things afterwards...</p>



<a name="185321652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321652">(Jan 10 2020 at 15:48)</a>:</h4>
<p>This is actually what IntelliJ does: <a href="https://github.com/intellij-rust/intellij-rust/blob/d23e13f8a7a9424795e9072f9806e2cbbb997989/src/main/kotlin/org/rust/ide/refactoring/implementMembers/impl.kt#L109" target="_blank" title="https://github.com/intellij-rust/intellij-rust/blob/d23e13f8a7a9424795e9072f9806e2cbbb997989/src/main/kotlin/org/rust/ide/refactoring/implementMembers/impl.kt#L109">https://github.com/intellij-rust/intellij-rust/blob/d23e13f8a7a9424795e9072f9806e2cbbb997989/src/main/kotlin/org/rust/ide/refactoring/implementMembers/impl.kt#L109</a></p>



<a name="185321867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321867">(Jan 10 2020 at 15:51)</a>:</h4>
<p>Hm, if I am reading this correctly, what IntelliJ does is that it <em>renders</em> types</p>



<a name="185321936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321936">(Jan 10 2020 at 15:52)</a>:</h4>
<p><a href="https://github.com/intellij-rust/intellij-rust/blob/55584ccf5159c0369a690f99aa15a309a681049b/src/main/kotlin/org/rust/lang/core/psi/RsPsiFactory.kt#L501-L502" target="_blank" title="https://github.com/intellij-rust/intellij-rust/blob/55584ccf5159c0369a690f99aa15a309a681049b/src/main/kotlin/org/rust/lang/core/psi/RsPsiFactory.kt#L501-L502">https://github.com/intellij-rust/intellij-rust/blob/55584ccf5159c0369a690f99aa15a309a681049b/src/main/kotlin/org/rust/lang/core/psi/RsPsiFactory.kt#L501-L502</a></p>



<a name="185321973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185321973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185321973">(Jan 10 2020 at 15:52)</a>:</h4>
<p><code>RsTypeReference</code> is AST, but <code>type</code>, I think, is <code>Ty</code></p>



<a name="185322036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185322036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185322036">(Jan 10 2020 at 15:53)</a>:</h4>
<p>And the rendering is here: <a href="https://github.com/intellij-rust/intellij-rust/blob/a92d97755f5458a2ea8ceac10407acaf15595cb9/src/main/kotlin/org/rust/ide/presentation/TypeRendering.kt#L39" target="_blank" title="https://github.com/intellij-rust/intellij-rust/blob/a92d97755f5458a2ea8ceac10407acaf15595cb9/src/main/kotlin/org/rust/ide/presentation/TypeRendering.kt#L39">https://github.com/intellij-rust/intellij-rust/blob/a92d97755f5458a2ea8ceac10407acaf15595cb9/src/main/kotlin/org/rust/ide/presentation/TypeRendering.kt#L39</a></p>



<a name="185322262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185322262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185322262">(Jan 10 2020 at 15:55)</a>:</h4>
<p>This actually seems like a nice middle ground: we render types, but copy-paste all the rest</p>



<a name="185324632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185324632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185324632">(Jan 10 2020 at 16:18)</a>:</h4>
<p>Hm... I've got the <code>AstSubst</code> approach working now <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="185324720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185324720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185324720">(Jan 10 2020 at 16:19)</a>:</h4>
<p>I think it's actually quite nice, the question would be whether the additional complexity pays off</p>



<a name="185324903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185324903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185324903">(Jan 10 2020 at 16:21)</a>:</h4>
<p>We can always rewrite later :D</p>



<a name="185333672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/doing%20multiple%20analysis/replacement%20steps/near/185333672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/doing.20multiple.20analysis.2Freplacement.20steps.html#185333672">(Jan 10 2020 at 17:53)</a>:</h4>
<p>see <a href="https://github.com/rust-analyzer/rust-analyzer/pull/2727/commits/0d16dbb340aae3ffccdc80132b61e1c8ced89de4" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/2727/commits/0d16dbb340aae3ffccdc80132b61e1c8ced89de4">https://github.com/rust-analyzer/rust-analyzer/pull/2727/commits/0d16dbb340aae3ffccdc80132b61e1c8ced89de4</a> for the result</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>